package com.backend.securitiessystem.service.impl;

import com.backend.securitiessystem.dao.IRiseFallDao;
import com.backend.securitiessystem.dto.RiseFallDto;
import com.backend.securitiessystem.pojo.RiseFall;
import com.backend.securitiessystem.service.RiseFallService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * 上升下降业务暗示
 *
 * @author LWY
 * @date 2024-05-23 03:38:31
 */
@Service
public class RiseFallServiceImpl extends ServiceImpl<IRiseFallDao, RiseFall> implements RiseFallService {


    @Override
    public IPage<RiseFallDto> selectPageWithCondition(int current, int size, QueryWrapper<RiseFall> queryWrapper) {
        Page<RiseFall> page1 = new Page<>(current, size);
        IPage<RiseFall> riseFallIPage = this.page(page1, queryWrapper);

        List<RiseFallDto> riseFallDtoList = new ArrayList<>();
        for (RiseFall riseFall : riseFallIPage.getRecords()) {
            RiseFallDto riseFallDto = new RiseFallDto();
            riseFallDto.setPlateName(riseFall.getPlateName());
            riseFallDto.setRanges(riseFall.getRanges());
            riseFallDto.setStatus(riseFall.getStatus());
            riseFallDtoList.add(riseFallDto);
        }

        IPage<RiseFallDto> riseFallDtoIPage = new Page<>();
        riseFallDtoIPage.setRecords(riseFallDtoList);
        riseFallDtoIPage.setTotal(riseFallIPage.getTotal());
        riseFallDtoIPage.setCurrent(current);
        riseFallDtoIPage.setSize(size);
        return riseFallDtoIPage;
    }

}
